package com.ostrich.cloud.ostrichUserService.app;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@SpringBootApplication(scanBasePackages = "com.ostrich.cloud.ostrichUserService")//多模块项目需要手动指定路径，扫描所有模块
@MapperScan("com.ostrich.cloud.ostrichUserService.infra.mapper")
@EnableFeignClients(basePackages = "com.ostrich.cloud.*.client")//扫描所有的feign-client，注意项目的包路径需要符合要求
public class OstrichUserServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(OstrichUserServiceApplication.class, args);
    }
    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowedOrigins("*")
                        .allowedMethods("*")//允许所有的请求方式
                        .allowedHeaders("*");
            }
        };
    }
}
